package Boke2;

import java.util.Timer;
import java.util.TimerTask;

public class UseTimer {
    public static void main(String[] args) throws InterruptedException {

        Timer timer=new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                while(true){
                    System.out.println("定时器任务执行中");
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        },3000);


        while(true){
            System.out.println("main执行中");
            Thread.sleep(500);
        }
    }

}
